/*
** threads.c for threads.c in /home/dd/projs/dayday/srcs/client/threads
** 
** Made by dd
** Login   <alletr_p@epitech.net>
** 
** Started on  Tue Jul 21 23:36:41 2009 dd
** Last update Wed Jul 22 12:56:07 2009 dd
*/

#include <assert.h>

#include "client.h"

#define GFX_THREAD	&gfx

int			threads(t_all *all)
{
  int			i;
  int			status;
  t_threads		*main_thread = NULL;
  extern t_threads	gl_threads[];

  assert(all);
  for (i = 0; gl_threads[i].f; i++)
    {
      gl_threads[i].param = (void *) all;
      if (gl_threads[i].f != GFX_THREAD)
	gl_threads[i].thread = SDL_CreateThread(&threads_entry, 
						(void *) &gl_threads[i]);
      else
	main_thread = &gl_threads[i];
    }
  threads_entry((void *) main_thread);
  for (i = 0; gl_threads[i].f; i++)
    SDL_WaitThread(gl_threads[i].thread, &status);
  return (SUCCESS);
}
